# Maintainer:
pkgname=kbs2
pkgver=0.7.2
pkgrel=3
pkgdesc="Secret manager backed by age"
url="https://github.com/woodruffw/kbs2"
# loongarch64: blocked by libc crate
arch="all !s390x !riscv64 !loongarch64" # blocked by cargo
license="MIT"
makedepends="cargo python3 cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/woodruffw/kbs2/archive/refs/tags/v$pkgver.tar.gz
	cargo-update-libc-lfs64.patch
	"


prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen

	./target/release/kbs2 --completions bash > kbs2.bash
	./target/release/kbs2 --completions fish > kbs2.fish
	./target/release/kbs2 --completions zsh > kbs2.zsh
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 "$builddir"/target/release/kbs2 \
		"$pkgdir"/usr/bin/kbs2
	install -Dm644 "$builddir"/kbs2.bash \
		"$pkgdir"/usr/share/bash-completion/completions/kbs2
	install -Dm644 "$builddir"/kbs2.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/kbs2.fish
	install -Dm644 "$builddir"/kbs2.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_kbs2
}

sha512sums="
9d74dfaa17702a44e20332618aa094e52899a1f27a6af35a65ef928f62d5dc0bebe1a8ed20618a89b8ae468d47cb6ef4608d538ec4d5b317f6f5d9338cf8b2b7  kbs2-0.7.2.tar.gz
8df79f751501a7c9ac85bd75c3c901113fb8e19d422b1074f7bde1d1503f23835a6b80a43f39999aac5f7099ebe24437fd90d66b20b9e9b355a65d774d206a43  cargo-update-libc-lfs64.patch
"
